/*
 * Wevo2 - Distributed Evolutionary Computation Library.
 * Copyright (C) 2009 Marcin Brodziak
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *    Boston, MA  02110-1301  USA
 */
package classifier.examples.operators;

import engine.Operator;
import engine.Population;

/**
 * This operator is used to save population in any point
 * of evolution. When applied to given population it only
 * make side-effect which results in saving population.
 * 
 * @author Lukasz Krawiec (lmkrawiec@gmail.com)
 * @author Michal Anglart (anglart.michal@gmail.com)
 * 
 * @param <T> Type of the individual in the population.
 */
public class SavePopulationOperator<T> implements Operator<T> {

    /** Population saved by operator. */
    private Population<T> savedPopulation = null;

    /**
     * Gets saved population.
     * @return Population saved in operator.
     */
    public Population<T> getSavedPopulation() {
      return savedPopulation;
    }

    /** {@inheritDoc} */
    public Population<T> apply(Population<T> population) {
      savedPopulation = new Population<T>(population);
      return population;
    }
}
